package search.eightpuzzle.astar;

import search.eightpuzzle.model.PuzzleState;

public class MismatchHeuristic implements Heuristic {

    @Override
    public int estimate(final PuzzleState current, final PuzzleState goal) {
        int mismatches = 0;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                final int currentVal = current.get(i, j);
                if (currentVal != 0) {
                    if (currentVal != goal.get(i, j)) {
                        ++mismatches;
                    }
                }
            }
        }
        return mismatches;
    }

}
